home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / ImageViewerBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  9KB  |  255 lines

  1. package symantec.itools.multimedia;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  08/04/97    LAB    Removed Centered property.  Removed setCentered and getCentered connections.
  8. //                    Added Style property.  Added setStyle, getStyle and Style constants as connections.
  9. //  09/11/97    LAB    Changed URL property and connections to ImageURL (Addresses Mac Bug #7689).
  10. //    09/19/97    RKM    Fixed bug in Normal style connection
  11. //                    Hid the font, foreground, and background properties - they did nothing
  12. //  08/19/98    LAB    Moved to GroupAWTMultimedia folder.
  13.  
  14. /**
  15.  * BeanInfo for ImageViewer.
  16.  *
  17.  */
  18.  
  19. public class ImageViewerBeanInfo extends SimpleBeanInfo {
  20.  
  21.     /**
  22.      * Constructs a ImageViewerBeanInfo object.
  23.      */
  24.     public ImageViewerBeanInfo() {
  25.     }
  26.  
  27.     /**
  28.      * Gets a BeanInfo for the superclass of this bean.
  29.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  30.      */
  31.     public BeanInfo[] getAdditionalBeanInfo() {
  32.         try {
  33.             BeanInfo[] bi = new BeanInfo[1];
  34.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  35.             return bi;
  36.         }
  37.         catch (IntrospectionException e) { throw new Error(e.toString());}
  38.     }
  39.  
  40.     /**
  41.      * Gets the SymantecBeanDescriptor for this bean.
  42.      * @return an object of type SymantecBeanDescriptor
  43.      * @see symantec.itools.beans.SymantecBeanDescriptor
  44.      */
  45.     public BeanDescriptor getBeanDescriptor() {
  46.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  47.         String s=group.getString("GroupAWTMultimedia"); 
  48.  
  49.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  50.         bd.setFolder(s);
  51.         bd.setToolbar(s);
  52.         bd.setWinHelp("0x123CA");
  53.  
  54.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  55.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  56.                                                 "%name%.IMAGE_TILED",
  57.                                                 conn.getString("IMAGE_TILED")));
  58.  
  59.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  60.                                                 "%name%.IMAGE_CENTERED",
  61.                                                 conn.getString("IMAGE_CENTERED")));
  62.  
  63.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  64.                                                 "%name%.IMAGE_SCALED_TO_FIT",
  65.                                                 conn.getString("IMAGE_SCALED_TO_FIT")));
  66.  
  67.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  68.                                                 "%name%.IMAGE_NORMAL",
  69.                                                 conn.getString("IMAGE_NORMAL")));
  70.  
  71.         return (BeanDescriptor) bd;
  72.     }
  73.  
  74.     /**
  75.      * Gets an image that may be used to visually represent this bean
  76.      * (in the toolbar, on a form, etc).
  77.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  78.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  79.      * @return an image for this bean, always color even if requested monochrome
  80.      * @see BeanInfo#ICON_MONO_16x16
  81.      * @see BeanInfo#ICON_COLOR_16x16
  82.      * @see BeanInfo#ICON_MONO_32x32
  83.      * @see BeanInfo#ICON_COLOR_32x32
  84.      */
  85.     public java.awt.Image getIcon(int iconKind) {
  86.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  87.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  88.             java.awt.Image img = loadImage("ImageViewerC16.gif");
  89.             return img;
  90.         }
  91.  
  92.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  93.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  94.             java.awt.Image img = loadImage("ImageViewerC32.gif");
  95.             return img;
  96.         }
  97.  
  98.         return null;
  99.     }
  100.  
  101.     /**
  102.      * Gets an array of descriptions of the methods used for "connections" by
  103.      * Visual CafΘ's Interaction Wizard.
  104.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  105.      * @return method descriptions for this bean
  106.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  107.      */
  108.     public MethodDescriptor[] getMethodDescriptors() {
  109.         Class[] args;
  110.         ConnectionDescriptor connection;
  111.         java.util.Vector connections;
  112.         java.util.Vector md = new java.util.Vector();
  113.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  114.  
  115.         try{
  116.             args = new Class[1];
  117.             args[0] = java.lang.String.class ;
  118.             MethodDescriptor setFileName = new MethodDescriptor(beanClass.getMethod("setFileName", args));
  119.  
  120.             connections = new java.util.Vector();
  121.             connection = new ConnectionDescriptor("input", "String", "",
  122.                                     "%name%.setFileName(%arg%);",
  123.                                     conn.getString("setFileName"));
  124.             connections.addElement(connection);
  125.  
  126.             setFileName.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  127.             md.addElement(setFileName);
  128.         } catch (Exception e) { throw new Error("setFileName:: " + e.toString()); }
  129.  
  130.         try{
  131.             args = null;
  132.             MethodDescriptor getImageURL = new MethodDescriptor(beanClass.getMethod("getImageURL", args));
  133.  
  134.             connections = new java.util.Vector();
  135.             connection = new ConnectionDescriptor("output", "URL", "",
  136.                                     "%name%.getImageURL()",
  137.                                     conn.getString("getImageURLIV"));
  138.             connections.addElement(connection);
  139.  
  140.             getImageURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  141.             md.addElement(getImageURL);
  142.         } catch (Exception e) { throw new Error("getImageURL:: " + e.toString()); }
  143.  
  144.         try{
  145.             args = new Class[1];
  146.             args[0] = java.net.URL.class ;
  147.             MethodDescriptor setImageURL = new MethodDescriptor(beanClass.getMethod("setImageURL", args));
  148.  
  149.             connections = new java.util.Vector();
  150.             connection = new ConnectionDescriptor("input", "RelativeURL", "",
  151.                                     "%name%.setURL(symantec.itools.net.RelativeURL.getURL(%arg%));",
  152.                                     conn.getString("setURLIV"));
  153.             connections.addElement(connection);
  154.  
  155.             connection = new ConnectionDescriptor("input", "URL", "",
  156.                                     "%name%.setImageURL(%arg%);",
  157.                                     conn.getString("setImageURLIV"));
  158.             connections.addElement(connection);
  159.  
  160.             setImageURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  161.             md.addElement(setImageURL);
  162.         } catch (Exception e) { throw new Error("setImageURL:: " + e.toString()); }
  163.  
  164.         try{
  165.             args = null;
  166.             MethodDescriptor getFileName = new MethodDescriptor(beanClass.getMethod("getFileName", args));
  167.  
  168.             connections = new java.util.Vector();
  169.             connection = new ConnectionDescriptor("output", "String", "",
  170.                                     "%name%.getFileName()",
  171.                                     conn.getString("getFileName"));
  172.             connections.addElement(connection);
  173.  
  174.             getFileName.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  175.             md.addElement(getFileName);
  176.         } catch (Exception e) { throw new Error("getFileName:: " + e.toString()); }
  177.  
  178.         try{
  179.             args = new Class[1];
  180.             args[0] = java.lang.Integer.TYPE;
  181.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("setStyle", args));
  182.  
  183.             connections = new java.util.Vector();
  184.             connection = new ConnectionDescriptor("input", "int", "",
  185.                                     "%name%.setStyle(%arg%);",
  186.                                     conn.getString("setStyleIV"));
  187.             connections.addElement(connection);
  188.  
  189.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  190.             md.addElement(setStyle);
  191.         } catch (Exception e) { throw new Error("setStyle:: " + e.toString()); }
  192.  
  193.         try{
  194.             args = null;
  195.             MethodDescriptor getStyle = new MethodDescriptor(beanClass.getMethod("getStyle", args));
  196.  
  197.             connections = new java.util.Vector();
  198.             connection = new ConnectionDescriptor("output", "String", "",
  199.                                     "%name%.getStyle()",
  200.                                     conn.getString("getStyleIV"));
  201.             connections.addElement(connection);
  202.  
  203.             getStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  204.             md.addElement(getStyle);
  205.         } catch (Exception e) { throw new Error("getStyle:: " + e.toString()); }
  206.  
  207.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  208.         md.copyInto(rv);
  209.  
  210.         return rv;
  211.     }
  212.  
  213.     /**
  214.      * Returns descriptions of this bean's properties.
  215.      */
  216.     public PropertyDescriptor[] getPropertyDescriptors() {
  217.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  218.  
  219.         try{
  220.         PropertyDescriptor style = new PropertyDescriptor("style", beanClass);
  221.         style.setBound(true);
  222.         style.setConstrained(true);
  223.         style.setDisplayName(prop.getString("imageStyle"));
  224.         style.setValue("ENUMERATION", "IMAGE_TILED=0, IMAGE_CENTERED=1, IMAGE_SCALED_TO_FIT=2, IMAGE_NORMAL=3");
  225.  
  226.         PropertyDescriptor imageURL = new PropertyDescriptor("imageURL", beanClass);
  227.         imageURL.setBound(true);
  228.         imageURL.setConstrained(true);
  229.         imageURL.setDisplayName(prop.getString("imageURL"));
  230.         imageURL.setValue("URLFILTER", prop.getString("imageURLFILTER"));
  231.         
  232.         //Hide the font, background, and foreground properties
  233.         PropertyDescriptor font = new PropertyDescriptor("font", beanClass);
  234.         font.setHidden(true);
  235.         
  236.         PropertyDescriptor background = new PropertyDescriptor("background", beanClass);
  237.         background.setHidden(true);
  238.         
  239.         PropertyDescriptor foreground = new PropertyDescriptor("foreground", beanClass);
  240.         foreground.setHidden(true);
  241.         
  242.         PropertyDescriptor[] rv = {
  243.             style,
  244.             imageURL,
  245.             font,
  246.             background,
  247.             foreground
  248.             };
  249.         return rv;
  250.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  251.     }
  252.  
  253.     private final static Class beanClass = ImageViewer.class;
  254.  
  255.     }    //  end of class ImageViewerBeanInfo